/* 
 *  Copyright 2012 CodeMagi, Inc.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.codemagi.servlets.model;

import java.io.Serializable;

/**
 * BaseBean is the superclass for all beans and Nodes in the CodeMagi web application framework. 
 *
 * @version 1.0
 * @author August Detlefsen for CodeMagi, Inc.
 */
public class BaseBean implements Serializable {

    private Integer id;
    private String  name;


    // GETTERS AND SETTERS -------------------------------------------

    public void setId(Integer newValue) {
        id = newValue;
    }

    public Integer getId() {
        return id;
    }

    public void setName(String newValue) {
        name = newValue;
    }

    public String getName() {
        return name;
    }


    // Object IMPLEMENTATIONS ----------------------------------------

    /**
     * equals method overridden to return true if the argument 
     * Object is an instance of the same class and has the same id.
     */
    public boolean equals(Object o) {
	return ( id != null && this.getClass().isInstance(o) && id.equals( ((BaseBean)o).getId() ) );
    }

    /**
     * toString method modified to output the ID of the bean.
     */
    public String toString() {
	return super.toString() + " (" + id + ") ";
    }
}
